/**
 * @author Simon Wielens
 * This class represents a college, which is a collection of faculties.
 */
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;

public class College implements Serializable 
{
	
	private static final long serialVersionUID = -634268016514566465L;
	private String collegeName;
	private ArrayList <Faculty> schools = new ArrayList<Faculty>();
	
	public College()
	{}
	
	public College(String name)
	{
		this.collegeName = name;
	}
	
	public void addSchool(Faculty f)
	{
		Faculty faculty = new Faculty();
		faculty = f;
		this.schools.add(faculty);
	}
	
	public void setSchools(ArrayList <Faculty> schools) {
		this.schools = schools;
	}

	public ArrayList <Faculty> getSchools() 
	{
		return schools;
	}

	public void setCollegeName(String collegeName) {
		this.collegeName = collegeName;
	}

	public String getCollegeName() {
		return collegeName;
	}
	
	public boolean contains(String name)
	{
		boolean isThere = false;
		Iterator<Faculty> iter = schools.iterator();
		while(iter.hasNext())
		{
			if(iter.next().getName().equals(name))
			{
				isThere = true;
				break;
			}
		}
		
		return isThere;
	}
	
	public void printAll()
	{
		Iterator<Faculty> it = schools.iterator();
		while(it.hasNext()) 
		{			
			Faculty f = it.next();
			System.out.println("Faculty Name is : "+f.getName());
			System.out.println("The address of it is: "+f.getAddress());
			System.out.println(f.getName() +"'s staff are:");
			f.printAll();
		}
	}
	
	public String[] returnFaculties()
	{
		String[] facs = new String[schools.size()+1];
		facs[0] = "Select Faculty";
		int count = 1;
		Iterator<Faculty> it = schools.iterator();
		while(it.hasNext()) 
		{
			facs[count] = it.next().getName();
			count++;
		}
		return facs;
	}
	
	public Faculty returnFacultyByName(String name)
	{
		Faculty fac = new Faculty();
		Iterator<Faculty> it = schools.iterator();
		while(it.hasNext()) 
		{	
			Faculty temp = it.next();
			if(temp.getName().equals(name))
			{
				fac = temp;
				break;
			}
		}
		
		return fac;
	}
}
